      SUBROUTINE read_mod 
!
      use mod_ioff
      use mod_iop
      use mod_orbit
      use mod_ri
      use mod_size
      use mod_symm
      implicit none 
!
      integer irrepi, i, j, k, irrepna, irrepnb
      integer isymoff(8,8,25), irrepa2(255,2), irpdpd(8,22)
      integer IOFF(2), IFLAGS(100)
      integer, external :: idsymsoc, irpdso
      character*12 :: string2
!---------read symm and orbit in "mod_symm and mod_orbit"
      OPEN(UNIT=1000, FILE='cc_interface', FORM='UNFORMATTED')
      REWIND 1000
      READ(1000) NOCCO(1), NOCCO(2), NVRTO(1), NVRTO(2)
      READ(1000) (((ISYMOFF(I,J,K),I=1,8),J=1,8),K=1,25) ! this data has been deprecated in ccsdsr
      READ(1000) ((POP(I,J),I=1,8),J=1,2)
      READ(1000) ((VRT(I,J),I=1,8),J=1,2)
      READ(1000) SYMRX, SYMRY, SYMRZ
      READ(1000) ISYMV
      READ(1000) ((IRREPA2(I,J),I=1,255),J=1,2) ! this data has been deprecated in ccsdsr
      READ(1000) ((DIRPRD(I,J),I=1,8),J=1,8)
      READ(1000) ((IRPDPD(I,J),I=1,8),J=1,22) ! this data has been deprecated in ccsdsr
      READ(1000)  NIRREP
      read(1000)  ilnbuf, iprcln, iprcwd
      read(1000)  ICRSIZ,ICHCSZ,(IOFF(i),i=1,2)
      read(1000) (IFLAGS(i),i=1,100) ! this data has been deprecated in ccsdsr
      CLOSE(1000)
      NVA = NVRTO(1)
      NVB = NVRTO(1)
      NOA = NOCCO(1)
      NOB = NOCCO(1)
      ZORB(1)=1
      ZORB(2:8)=0
      VRTA(1:8) = VRT(1:8,1)
      VRTB(1:8) = VRT(1:8,1)
      POPA(1:8) = POP(1:8,1)
      POPB(1:8) = POP(1:8,1)
      ! nv and no was defined for nospin codes with symmetry
      do irrepna = 1, 8 
         irrepnb = dirprd(irrepna, symry)
         nv(irrepna) = vrta(irrepna)+vrtb(irrepnb)
         no(irrepna) = popa(irrepna)+popb(irrepnb)
      enddo
!------------------------------------------------------------
!------------------------------------------------------------
!---for mod_iop
      ldebug=.true.                 !for debug
!
      prec=8; isd=2; igpu=0; totgpu=0
      call readinp
!
      igpu=0 ;isd=prec/4    ! igpu for choosing whehter in CPU or in GPU for special calculation part
      ioiabcd=0; ioiabci=0; iowmbej=0 ! io& for whether save integrals in disk or memory
      igpuabci=0; igpuabcd=0  !igpuabci and igpuabcd for whether save all integrals in cpu or gpu
!
!     cc_int = 1  ! for choose where to get the integrals, =1 for cfour and =2 for amesp
!
!
!------------------------------------------------------------
!------------------------------------------------------------
!---for mod_size and mod_ioff
     icrsiz = 1024*1024*1024/4*60  !80GB   memory size 
     igpusize= 1024*1024*1024/4*10 !10GB   gpu size
     nvvv=1; nvvvv=1; nvvvo=1; nvvoo=1; nvooo=1; noooo=1
     do irrepi = 1, nirrep 
        nvvv  = max(nvvv , idsymsoc(irrepi, vrta, vrta, 1, vrta, zorb, 1))
        nvvv  = max(nvvv , idsymsoc(irrepi, vrtb, vrtb, 1, vrtb, zorb, 1))
        nvvv  = max(nvvv , idsymsoc(irrepi, vrta, vrta, 1, vrtb, zorb, 1))
        nvvv  = max(nvvv , idsymsoc(irrepi, vrta, vrtb, 1, vrtb, zorb, 1))
!
        nvvvv = max(nvvvv, idsymsoc(irrepi, vrta, vrta, 1, vrta, vrta, 1))
        nvvvv = max(nvvvv, idsymsoc(irrepi, vrtb, vrtb, 1, vrtb, vrtb, 1))
        nvvvv = max(nvvvv, idsymsoc(irrepi, vrta, vrta, 1, vrtb, vrtb, 1))
!
        nvvvo = max(nvvvo, idsymsoc(irrepi, vrta, vrta, 1, vrta, popa, 1))
        nvvvo = max(nvvvo, idsymsoc(irrepi, vrtb, vrtb, 1, vrtb, popb, 1))
        nvvvo = max(nvvvo, idsymsoc(irrepi, vrta, vrtb, 1, vrta, popb, 1))
        nvvvo = max(nvvvo, idsymsoc(irrepi, vrtb, vrta, 1, vrtb, popa, 1))
!
        nvvoo = max(nvvoo, idsymsoc(irrepi, vrta, vrta, 1, popa, popa, 1))
        nvvoo = max(nvvoo, idsymsoc(irrepi, vrta, vrtb, 1, popa, popb, 1))
        nvvoo = max(nvvoo, idsymsoc(irrepi, vrtb, vrtb, 1, popb, popb, 1))
        nvvoo = max(nvvoo, idsymsoc(irrepi, vrta, vrta, 1, popb, popb, 1))
        nvvoo = max(nvvoo, idsymsoc(irrepi, vrtb, vrtb, 1, popa, popa, 1))
!
        nvooo = max(nvooo, idsymsoc(irrepi, vrta, popa, 1, popa, popa, 1))
        nvooo = max(nvooo, idsymsoc(irrepi, vrtb, popb, 1, popb, popb, 1))
        nvooo = max(nvooo, idsymsoc(irrepi, vrta, popb, 1, popa, popb, 1))
        nvooo = max(nvooo, idsymsoc(irrepi, vrtb, popa, 1, popb, popa, 1))
!
        noooo = max(noooo, idsymsoc(irrepi, popa, popa, 1, popa, popa, 1))
        noooo = max(noooo, idsymsoc(irrepi, popb, popb, 1, popb, popb, 1))
        noooo = max(noooo, idsymsoc(irrepi, popa, popb, 1, popa, popb, 1))
     enddo
!---ifvv aa bb
     ifvv(1) = 1
     ifvv(2) = ifvv(1)
     ifvv(3) = ifvv(2) + irpdso(1, vrtb, vrtb, 1)*isd
     nifvv   = (ifvv(3) - 1)/isd
     nifvvaa = (ifvv(3)-ifvv(1))/isd
     nifvvbb = (ifvv(3)-ifvv(2))/isd 
!---ifoo aa bb
     ifoo(1) = 1
     ifoo(2) = ifoo(1) 
     ifoo(3) = ifoo(2) + irpdso(1, popb, popb, 1)*isd
     nifoo = (ifoo(3) - 1)/isd
     nifooaa = (ifoo(3) - 1)/isd
     nifoobb = (ifoo(3) - ifoo(2))/isd
!---ifvo aa bb
     ifvo(1) = 1
     ifvo(2) = ifvo(1) 
     ifvo(3) = ifvo(2) + irpdso(1, vrtb, popb, 1)*isd
     nifvo = (ifvo(3) - 1)/isd
     nifvoaa = (ifvo(3)-ifvo(1))/isd
     nifvobb = (ifvo(3)-ifvo(2))/isd
!!---wmnij and iijkl === aaaa abab bbbb baba, aabb, bbaa
     ioi1(1) = 1
     ioi1(2) = ioi1(1) 
     ioi1(3) = ioi1(2) + idsymsoc(1, popa, popb, 1, popa, popb, 1)*isd
     ioi1(4) = ioi1(3) 
     nioi1 = (ioi1(4) - 1)/isd
     nioi11 = idsymsoc(1, popa, popa, 0, popa, popa, 0)
     nioi12 = idsymsoc(1, popa, popb, 1, popa, popb, 1)
     nioi13 = idsymsoc(1, popb, popb, 0, popb, popb, 0)
!---ioi2 for iijka
     ioi2(1) = 1
     ioi2(2) = ioi2(1) 
     ioi2(3) = ioi2(2) + idsymsoc(1, popa, popb, 1, popa, vrtb, 1)*isd
     ioi2(4) = ioi2(3) 
     ioi2(5) = ioi2(4) 
     nioi2 = (ioi2(5) - 1)/isd
     nioi21 = idsymsoc(1, popa, popa, 0, popa, vrta, 1) 
     nioi22 = idsymsoc(1, popa, popb, 1, popa, vrtb, 1)
     nioi23 = idsymsoc(1, popb, popb, 0, popb, vrtb, 1) 
     nioi24 = idsymsoc(1, popb, popa, 1, popb, vrta, 1) 
!---ioi3 for iabij, t1 and t2
     ioi3(1) = 1
     ioi3(2) = ioi3(1) 
     ioi3(3) = ioi3(2) + idsymsoc(1, vrta, vrtb, 1, popa, popb, 1)*isd
     ioi3(4) = ioi3(3)
!    ioi3(2) = ioi3(1) + idsymsoc(1, vrta, vrta, 0, popa, popa, 0)*isd
!    ioi3(3) = ioi3(2) + idsymsoc(1, vrta, vrtb, 1, popa, popb, 1)*isd
!    ioi3(4) = ioi3(3) + idsymsoc(1, vrtb, vrtb, 0, popb, popb, 0)*isd  
     nioi3 = (ioi3(4) - 1)/isd
     nioi31 = idsymsoc(1, vrta, vrta, 0, popa, popa, 0)
     nioi32 = idsymsoc(1, vrta, vrtb, 1, popa, popb, 1)
     nioi33 = idsymsoc(1, vrtb, vrtb, 0, popb, popb, 0)
!---wmbej and iiabj === aaaa abab bbbb baba aabb bbaa
     ioi4(1) = 1
     ioi4(2) = ioi4(1) + idsymsoc(1, vrta, popa, 1, vrta, popa, 1)*isd
     ioi4(3) = ioi4(2) + idsymsoc(1, vrta, popb, 1, vrta, popb, 1)*isd
     ioi4(4) = ioi4(3) 
     ioi4(5) = ioi4(4) 
     ioi4(6) = ioi4(5) + idsymsoc(1, vrta, popa, 1, vrtb, popb, 1)*isd
     ioi4(7) = ioi4(6)
     nioi4 = (ioi4(7) - 1)/isd
     nioi41 = idsymsoc(1, vrta, popa, 1, vrta, popa, 1) 
     nioi42 = idsymsoc(1, vrta, popb, 1, vrta, popb, 1)
     nioi43 = idsymsoc(1, vrtb, popb, 1, vrtb, popb, 1) 
     nioi44 = idsymsoc(1, vrtb, popa, 1, vrtb, popa, 1) 
     nioi45 = idsymsoc(1, vrta, popa, 1, vrtb, popb, 1) 
     nioi46 = idsymsoc(1, vrtb, popb, 1, vrta, popa, 1) 
!---ioi5 for iabci 
     ioi5(1) = 1
     ioi5(2) = ioi5(1) 
     ioi5(3) = ioi5(2) + idsymsoc(1, vrta, vrtb, 1, vrta, popb, 1)*isd
     ioi5(4) = ioi5(3) 
     ioi5(5) = ioi5(4) 
     nioi5 = (ioi5(5) - 1)/isd
     nioi51 = idsymsoc(1, vrta, vrta, 0, vrta, popa, 1)
     nioi52 = idsymsoc(1, vrta, vrtb, 1, vrta, popb, 1)
     nioi53 = idsymsoc(1, vrtb, vrtb, 0, vrtb, popb, 1)
     nioi54 = idsymsoc(1, vrtb, vrta, 1, vrtb, popa, 1)
!---ioi6 for iabcd
     ioi6(1) = 1
     ioi6(2) = ioi6(1) + idsymsoc(1, vrta, vrta, 0, vrta, vrta, 0)*isd 
     ioi6(3) = ioi6(2) + idsymsoc(1, vrta, vrta, 2, vrta, vrta, 2)*isd 
     ioi6(4) = ioi6(3) 
     nioi6 = (ioi6(4) - 1)/isd
     nioi61 = idsymsoc(1, vrta, vrta, 0, vrta, vrta, 0)
     nioi62 = idsymsoc(1, vrta, vrtb, 2, vrta, vrtb, 2)
     nioi63 = idsymsoc(1, vrtb, vrtb, 0, vrtb, vrtb, 0)
!
     END
  
